<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body>
<div style="padding: 15px">
    <form class="layui-form" action="">
        <div class="layui-row">
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">角色名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="roleName" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">权限字符</label>
                        <div class="layui-input-inline">
                            <input type="text" name="roleKey" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">显示顺序</label>
                        <div class="layui-input-inline">
                            <input type="text" name="roleSort" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <select name="status" id="status" lay-verify="required" lay-search="">
                                <option value="0">正常</option>
                                <option value="1">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">数据范围</label>
                        <div class="layui-input-inline">
                            <select name="status" id="dataScope" lay-verify="required" lay-search="">
                                <option value="1">所有数据权限</option>
                                <option value="2">自定数据权限</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-inline">
                            <input type="text" name="remark" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单权限</label>
                    <div class="layui-input-inline">
                        <div id="menuTrees" class="ztree"></div>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="role">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript" th:src="@{/jquery-ztree/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var sysUrl = '/venus/system/role';
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = parent.layer === undefined ? layui.layer : top.layer;
        //树形菜单
        var options = {
            id: "menuTrees",
            url: '/venus/system/menu/roleMenuTreeData',
            check: {enable: true, nocheckInherit: true, chkboxType: {"Y": "ps", "N": "ps"}},
            expandLevel: 0
        };
        $.tree.init(options);

        form.on('submit(role)', function (data) {
            data.field.menuIds=$.tree.getCheckedNodes();
            save(sysUrl, 'add', data.field);
            return false;
        });
    });
    /*]]>*/
</script>
</body>
</html>